class DataController < ApplicationController
  caches_page :search
  def search
    begin
      if request.post?
        if params[:ops][:card] == '1'
         @html_title = "你是个好人 - 河童子"
          render :action =>'card', :layout => 'simple', :status => 500
        else
         redirect_to searchget_path(params[:ops][:wid],params[:ops][:avid])
        end
      else #get
       @res = Pg::WeeklyResult.first :include => :weekly_result_work,
                                   :conditions => ["weekly_result_works.wid = ? and weekly_id = ?", params[:avid], params[:wid]]
       if @res
         @html_title = "av#{@res.wid}的查找结果 - 周刊哔哩哔哩排行榜"
         render :layout => 'simple'
       else
         @html_title = "查找错误 - 周刊哔哩哔哩排行榜"
         if Pg::WeeklyExcept.find_by_wid_and_weekly_id params[:avid], params[:wid]
           render :action =>'except', :layout => 'simple', :status => 500
         else
           render :action =>'not_found', :layout => 'simple', :status => 500
         end
       end
      end
    rescue
      RAILS_DEFAULT_LOGGER.error "#{$!}"
      RAILS_DEFAULT_LOGGER.error "#{$@}"
       @html_title = "查找错误 - 周刊哔哩哔哩排行榜"
       render :action =>'have_empty', :layout => 'simple', :status => 500
    end
  end

  def fengmian
    require 'RMagick'
    @work = Work.find_by_wid params[:id]
  end
end
